<template>
    <div class="zhiweimiaoshu EditResumeInfo jobcommon">
        <div class="popBody">
            <div class="backnavjob">
                <h1 @click="closejibenxinxi('close')">
                    <img
                        data-v-61dd7a3d=""
                        src="../../assets//newimg/index/icon_right_h.png"
                        alt=""
                    />
                </h1>
                <h2>
                    <span>年龄要求</span>
                </h2>
                <h3></h3>
            </div>
        </div>
        <div class="popBody">
            <div class="split-block"></div>
            <div class="list_height plist-txt notarrow">
                <div class="pic"></div>
                <div class="tit font14">最低年龄</div>
                <div class="describe font12">
                    <input
                        type="text"
                        id="tpl_minage"
                        placeholder="最低年龄"
                        value=""
                        class="font13"
                        v-model="age1"
                    />
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>
            <div class="list_height plist-txt notarrow">
                <div class="pic"></div>
                <div class="tit font14">最高年龄</div>
                <div class="describe font12">
                    <input
                        type="text"
                        id="tpl_maxage"
                        placeholder="最高年龄"
                        value=""
                        class="font13"
                        v-model="age2"
                    />
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="j_newbutton">
            <div class="j_newbtn" @click="closejibenxinxi()">保存</div>
        </div>
    </div>
</template>

<script>
// import { axiosPost } from '../../axios';
import { Toast } from 'vant';
export default {
    name: '',
    props: ['age'],
    data() {
        return {
            nage: '',
            age1: '',
            age2: '',
        };
    },
    computed: {},
    mounted() {
        if (this.age) {
            this.age1 = this.age[0];
            this.age2 = this.age[1];
        }
    },
    methods: {
        closejibenxinxi(type) {
            if (type) {
                this.$emit('closeProps', { type: 3, key: false });
                return;
            }
            if (!this.age1 || !this.age2) {
                return Toast({
                    message: '请输入年龄',
                    duration: 2000,
                });
            }
            if (!/^[0-9]*$/.test(this.age1) || !/^[0-9]*$/.test(this.age2)) {
                return Toast({
                    message: '请输入纯数字年龄',
                    duration: 2000,
                });
            }

            if (this.age1 >= this.age2) {
                return Toast({
                    message: '最大年龄要大于最小年龄',
                    duration: 2000,
                });
            }

            this.$emit('closeProps', {
                type: 3,
                key: true,
                data: [this.age1, this.age2],
            });
        },
    },
};
</script>

<style lang="less" scope></style>
